<template>
  <div class="hello">
    <h1></h1>
    <ul>
      <li><a href="https://github.com/joneqian/vue2-express" target="_blank">打个广告，看不看，你随意！！！</a></li>
      <li><a href="#" @click.prevent="jump('http://www.baidu.com')">jump 测试！！！</a></li>
    </ul>
    {{msg}}
    <table>
      <tr>
        <th>ID</th>
        <th>NAME</th>
      </tr>
      <tr v-for="user in users" v-bind:key="user.id">
        <td>{{user.id}}</td>
        <td>{{user.name}}</td>
      </tr>
    </table>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';

export default {
  name: 'hello',
  data() {
    return {
      msg: '少年，把你的代码撸起来，不要停！！！',
      users: {}
    };
  },
  methods: {
    ...mapMutations(['UPDATE_CUSTOMER_INFO']),
    getCustomerInfo() {
      this.UPDATE_CUSTOMER_INFO({});
    }
  },
  created () {
    this.$http('/users/list', {}, 'get').then(res => {
      this.users = res;
    }).catch(err => {
      console.log(err);
    });
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
